<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<title>Example 15 (HTML5 Audio)</title>
		<script>

			// You should use the "alt" version of this file, this is just an example on how to add multiple sources dynamically
			window.onload = function() {

				// Define an array with the audio files to try
				var sources = [
					["../sounds/song.mp3", "audio/mp3"],
					["../sounds/song.ogg", "audio/ogg"]
				];

				// Create the HTML5 Audio tag
				var audio = document.createElement('audio');

				// Cycle the "sources" array
				for (var i = 0; i < sources.length; i++) {

					// Create a source parameter
					var src = document.createElement('source');
					// Add both src and type attributes
					src.setAttribute("src", sources[i][0]);
					src.setAttribute("type", sources[i][1]);

					// Append the source to the Audio tag
					audio.appendChild(src);
				}

				// Attempt to play the sound
				audio.play();

			}
		</script>
    </head>
    <body>
    	HTML5 Audio tag example.
    </body>
</html>